Re: [GENERAL] Quoting/Escaping

Поиск
Список
Период
Сортировка
От Herouth Maoz
Тема Re: [GENERAL] Quoting/Escaping
Дата
Msg-id l03130301b4684ba9482e@[147.233.159.109]
обсуждение исходный текст
Ответ на Quoting/Escaping  (Bill Sneed <bsneed@mint.net>)
Список pgsql-general
At 23:21 +0200 on 28/11/1999, Bill Sneed wrote:


> I'd like to be able to find a book title that contain C++ in the
> title....
>
> select * from books where title ~* 'C++'   doesn't work.
>
> I've tried all the basic methods of quoting the Plus (+) signs but
> none seem to work...
>
> Any hints would be most appreciated....

testing=> select * from test1;
tx
------------------------------------------------
I prefer Java to C++ programming.
C++ is the most complicated of all OO langagues.
Java has less inheritance, but it is simpler.
(3 rows)
testing=> select * from test1 where tx ~* 'C\\+\\+';
tx
------------------------------------------------
I prefer Java to C++ programming.
C++ is the most complicated of all OO langagues.
(2 rows)

Rationale: the string is processed in two stages. One, when the query is
read by Postgres. The other, when the regexp engine reads it. It needs to
have backslashes before the pluses when it reaches the second stage. So the
backslashes have to pass intact through the first stage. Thus, they have to
be escaped themselves...

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herouth/personal/



В списке pgsql-general по дате отправления:

Предыдущее
От: jose soares
Дата:
Сообщение: Re: [GENERAL] update view
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] Re: [GENERAL] drop/rename table and transactions